import 'package:dartkit/dartkit.dart';
import 'package:test/test.dart';

void main() {
  test("极小概率不重复", () {
    // 比如说，已经存在0-8，系统唯一的选择就是生产9
    List<String> exists = ["0", "1", "2", "3", "4", "5", "6", "7", "8"];
    final generated = Generate.unique<String>(exists, () => Generate.number(1));
    // 生成的数字必定是9
    expect(generated, "9");
  });

  test("绝对重复", () {
    // 比如说，已经存在0-9，已经不可能生成任何新的值
    List<String> exists = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
    expect(
        () => Generate.unique<String>(exists, () => Generate.number(1)), isBug);
  });
}
